/**
 * 
 */
package edu.cmich.cps.cps240.partyprincesspalace.hw06;

import static org.junit.Assert.*;

import java.awt.Point;
import java.awt.Rectangle;
import java.util.Vector;

import org.junit.Test;

/**
 * @author roric1je
 *
 */
public class ChipPinTest {

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#getParent()}.
	 */
	@Test
	public void testGetParent() {
		ChipPin pinfail = new ChipPin(null, null, null);
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		
		Chip chip = new Chip(null, ins, outs, null);
		ChipPin pinwin = new ChipPin("Pin", chip, null);
		
		assertNull(pinfail.getParent());
		assertNotNull(pinwin.getParent());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#setParent(edu.cmich.cps.cps240.partyprincesspalace.hw06.WorkspaceObj)}.
	 */
	@Test
	public void testSetParent() {
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		Chip chip = new Chip(null, ins, outs, null);
		ChipPin pinwin = new ChipPin("Pin", chip, null);
		pinwin.setParent(null);
	
		assertNotNull(pinwin.getParent());
		
		pinwin.setParent(chip);
		assertNotNull(pinwin.getParent());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#getPartner()}.
	 */
	@Test
	public void testGetPartner() {
		WirePin partner = new WirePin("Partner", null, null);
		ChipPin pinfail = new ChipPin(null, null, null);
		assertNull(pinfail.getPartner());
		
		ChipPin pinwin = new ChipPin(null, null, partner);
		assertNotNull(pinwin.getPartner());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#setPartner(edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin)}.
	 */
	@Test
	public void testSetPartner() {
		WirePin partner = new WirePin(null, null, null);
		ChipPin pinwin = new ChipPin(null, null, partner);
		pinwin.setPartner(null);
	
		assertNull(pinwin.getParent());
		
		pinwin.setPartner(partner);
		assertNotNull(pinwin.getPartner());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#getName()}.
	 */
	@Test
	public void testGetName() {
		ChipPin pinfail = new ChipPin(null, null, null);
		ChipPin pinwin = new ChipPin("Chip", null, null);
		assertNull(pinfail.getName());
		assertNotNull(pinwin.getName());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#setName(java.lang.String)}.
	 */
	@Test
	public void testSetName() {
		ChipPin pinwin = new ChipPin("Chip", null, null);
		pinwin.setName(null);
		assertNotNull(pinwin.getName());
		pinwin.setName("Chip");
		assertNotNull(pinwin.getName());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#isInput()}.
	 */
	@Test
	public void testIsInput() {
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		
		Chip chip = new Chip(null, ins, outs, null);
		ChipPin pinwin = new ChipPin("Pin", chip, null);
		assertFalse(pinwin.isInput());
		ins.add(pinwin);
		assertTrue(pinwin.isInput());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#isOutput()}.
	 */
	@Test
	public void testIsOutput() {
		Vector<ChipPin> outs = new Vector<ChipPin>();
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Chip chip = new Chip(null, ins, outs, null);
		ChipPin pinwin = new ChipPin("Pin", chip, null);
		assertFalse(pinwin.isOutput());
		outs.add(pinwin);
		assertTrue(pinwin.isOutput());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#ChipPin(java.lang.String, edu.cmich.cps.cps240.partyprincesspalace.hw06.Chip, edu.cmich.cps.cps240.partyprincesspalace.hw06.WirePin)}.
	 */
	@Test
	public void testChipPinStringChipWirePin() {
		ChipPin pinfail = null;
		assertNull(pinfail);
		
		ChipPin pinwin = new ChipPin(null, null, null);
		assertNotNull(pinwin);
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#ChipPin(edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin)}.
	 */
	@Test
	public void testChipPinChipPin() {
		ChipPin pinfail = null;
		assertNull(pinfail);
		
		ChipPin pinwin = new ChipPin(null, null, null);
		assertNotNull(pinwin);
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#getLocation()}.
	 */
	@Test
	public void testGetLocation() {
		ChipPin pinwin = new ChipPin(null, null, null);
		assertNotNull(pinwin.getLocation());
		
		Point spot = new Point(5, 5);
		pinwin.setLocation(spot);
		assertNotNull(pinwin.getLocation());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#setLocation(java.awt.Point)}.
	 */
	@Test
	public void testSetLocation() {
		ChipPin pinwin = new ChipPin(null, null, null);
		assertNotNull(pinwin.getLocation());
		
		Point spot = new Point(5, 5);
		pinwin.setLocation(spot);
		assertNotNull(pinwin.getLocation());
		
		spot.setLocation(4, -5);
		pinwin.setLocation(spot);
		assertNotNull(pinwin.getLocation());
		int y = (int) pinwin.getLocation().getY();
		assertEquals(-5, y);
		
		spot.setLocation(-2, 2);
		pinwin.setLocation(spot);
		assertNotNull(pinwin.getLocation());
		y = (int) pinwin.getLocation().getY();
		assertEquals(2, y);
		
		spot.setLocation(-2, -2);
		pinwin.setLocation(spot);
		assertNotNull(pinwin.getLocation());
		y = (int) pinwin.getLocation().getY();
		int x = (int) pinwin.getLocation().getX();
		assertEquals(-2, y);
		assertEquals(-2, x);
		
		
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.ChipPin#closeToPin(java.awt.Point)}.
	 */
	@Test
	public void testCloseToPin() {
		Point spot = new Point(5, 5);
		ChipPin pinwin = new ChipPin(null, null, null);
		pinwin.setLocation(spot);
		assertTrue(pinwin.closeToPin(pinwin.getLocation()));
	}

}
